package com.devframe.srtp.server;

import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;

import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

import com.devframe.srtp.Account;
import com.devframe.srtp.server.support.SRTPServerPipelineFactory;


public class SRTPServer {
    public void run() {
        ServerBootstrap bootstrap = new ServerBootstrap(
                new NioServerSocketChannelFactory(
                        Executors.newCachedThreadPool(),
                        Executors.newCachedThreadPool()));
        bootstrap.setPipelineFactory(new SRTPServerPipelineFactory());
        bootstrap.bind(new InetSocketAddress(SRTPServerContainer.getInstance().getPort()));
    }
    
    public void init(){
    	this.run();
    }
    
    

//    public static void main(String[] args) {
//    	List<Account> accountList=new ArrayList<Account>();
//    	Account item=new Account();
//    	item.setLevel(1);
//    	item.setPwd("zbs");
//    	item.setUserName("zbs");
//    	item.setRootPath("D:/logs/server");
//    	accountList.add(item);
//    	SRTPServerContainer container=new SRTPServerContainer();
//    	container.setAccounts(accountList);
//    	container.setSrtpBaseDirectory("D:/logs");
//    }

}
